fixed some lurking bugs