refactor v4 complete, implemented pub sub, removed dependencies where possible