Fixing various bugs from cleanup