Many fixes for core and script core, new state for compilation