Added some additional checks for invalid user input.
Switched on compiler warnings (excepting the ones produced by external
libraries).