bug fixes and cleanup in lecture 04