Error handling/Small bug fixes