Fix serious bugs