adjust code format to fit the rest of the project

When in Rome, code as the Romans do.
do not reference a negative array offset when current_pos = 0

move wraparound handlers to helper functions
Merge pull request #7 from boundary/rma_fixes

Rma fixes