License headers inserted.
Getters style fixes

Code deduplication.
Removed some debug output and unused functions.
Reply function deduplication