Some urgent bug fixes