small refacktoring
continue refacktoring
oops, forgot add bunch of files
fix encoding recognizer