In my simple mind, if software has been "released" it is no longer R&D, and "bug fixes" (which should include continuous improvements such as your example) are not research.
That seems too exploitable to pass muster in the court. If you release Beta 0.0.1 of your software after 2 months of development then spend the next 5 years getting it up to version 1.0 that's clearly a development effort not a maintenance effort.
No. That is why you have auditors who must sign off on your financial books and records. There are fairly strict rules about capitalization of software development. If it is a meaningful number for your firm, then the auditors will review in detail.