Removing terrible looking javascript alerts and replacing them with real errors