Improved error handling
Whitespace
Const correctness