Tidying Code

Mostly tidying the code to make it look neater and for readability.