syntax consistency and breaking out functions into individual files for better readability

Weiyi,

Please review these changes. As of yet, they really do not change any content, just re-organize for easier review. It should be a good test of if "pull requests" will be a good way forward for collaborating on this package.

Thanks!