Fix various minor bugs and change exception catch style away from deprecated syntax