Fix bugs in initial checkin