Removed some unused code and added alot of comments