Use const where necessary
Do some much needed refactoring