Bug fixes for backend.