Added logging and fixed a BufferedReader bug