Fixed capitalization error. Added command-line mode.
Added comments and debugging output.