Refactored code into a library so that it can be imported by other projects as well as be used as well as a standalone binary.