Refactoring

Separete source code into main and library