Small but crucial bug fixes