Preliminary bug fixes