Formatting code and fixing general bugs, (Was an accident to do both in one commit)