Moving general code to Misc_code