Further fixes and implementing statistics module