Bug fixes and small changes