Improve style and optimize acceleration

Change: refactor and improve formatting of code.
Change: improve documentation of acceleration routine.
Change: speed up acceleration by merging acceleration conditions and
inlining acceleration routine.