More code refractoring, new features, major fixes and improvements