Cleaned up code a shitload