Fixed error on instances creation. General improvements