-refactored code in esp
-adapted slave code to account for 2 phase training
-slight bugfixes