Merged in changes Djphil sent