Fixed a couple of errors and refactored the code and added median reporting of bail amounts