Minor debug, issues fixed, new function