Bug fixes from testing