Split into lib and filter register

This allows including the library in cmder without having to modify
the source file. And also it separates the concerns nicely.