cleaned up unused code and added comments