Made functions and parameters const wherever possible. Fixed memoryleaks by adjusting destructors.
Merge branch 'const-ness' into develop