Minor bugfixes and small improvements in data handling