fixed null pointers and Thetus-specific changes