Sync with latest version from myc
Clean up code