Fixed names and organized and improved code