Optimization: Removed unnecessary error handlers and added more comments.