Feature/names fix 17 dev

"Less code - less problems"

1) Added compatibility for both versions: PD8 and PD9 (I've tested by myself). 
2) Merged 'read-*' functions for VMs and templates
3) Some refactoring done - unused functions was deteted

There are some serious code changes, thats why I've decided to make a pull request instead commit.
@yshahin , @wizonesolutions , what do you think about it?

P.s. Advice: Test this changeset after merging with current `master`