Second set of bug fixes