Arjun's bugfixes