Essential bug fixes