Cleaned up style, added comments