Bug fixes

Some bug fixes, now it should word correctly