various updates and tweaks, new cd function (separated from functions)