closes #750 also refactor core functions moved to proper places