Added histogram plotting. Still need to check bugs