Bug fixes

Fixed multiple small issues.