Refactor init stage (some fixes)
Refactor init stage and bugfixes