Datastructures

Small fixes to improve stability, please verify that these changes also work on other systems before merging.