Added logic for required text fields. Various cleanups