Added error checking and command line arguments processing stuff