Various 500 error fixes