Few fixes, Refactoring and fix to aggregations #10