Bugfixes

Solutions for bugs #1 and #2