Updated input validation and other minor fixes as suggested by Piazza.