Error handling added

Program no longer blindly trusts user input. All input from user is now
properly checked and handled.