fix cd reset, cleanup code - FINAL VERSION