[Andr] to preMaster

this is not simple commit with a few code refactoring. Also some necessary methods was implemented. Too far from perfect...