Clean up input handling
Fix uninitialised variable
Add C++11 support