Added log prior, fixed a couple of I/O bugs