Bug fixes 1-7