Improving custom error and some other minor stuff