Minor changes and optimizations. Added commentary to both files.