Added core and fixed bugs