Complete refactor. Added configuration feature.
complete refactor of internals