Size-induced undercooling and overheating in phase transitions in bare and embedded clusters