Converted into library project

- small changes to make it usable in other contexts