self has caused issues with serialization. Be explicit with val self = this where needed.