New code with phase 1 implemented

Test and train phases implemented