Base functional code added.

Pending improvements in code readability and comments.