fixes various bugs