Code cleaned up, error handling and messages finished