Fix factory creation & Code cleanup