Fixed some minor bugs + added more code comments