Fixing debugs, improving code before rebase