Phase1

I've rewritten phase 1 so it's easier to read and fixed some errors, unfortunately I still don't pass the test, but I'm not sure if it's because I'm not able to have a socket connection, or because of all the errors kept inside.

I didn't change too much in Log - just fixed few Java errors (accessing Array at index Array.size() - overflow, ...) so maybe we'll need to have a closer look at it if the things are correctly implemented by the paper