fixes #35

- fixed Endsession bug
- Various other small changes