Cleaned up some code

- Removed useless code
- Straightened out the rest of the code