Fixed error handling and realizing I should go to sleep now.