Clean
Makefile modification.
Small changes, coping with bugs.

Changes:
 - separate code into functions

 - changes some names

 - modify structures