Cleaned up code.  Compiled with -pendantic