Bugfixes, Refactorization, Added Makefile and some includes.

Bugfixes, Refactorization, Added Makefile and some includes.