Optimisation plus minor additions

Removed obsolete headers, whitespace, odd code and added code to better
math the problem specification