Various bugfixes, improvements, fix pyro class.