- fixed possible crashes
- removed compiler warnings
- code cleanup