Compiled optimised and code tidy up