Removed some unused code and fixed a massive bug from the last commit