Improved error handeling and added more API endpoints