Updated commenting, minor refactoring, removed unnecessary function