Added main entry point and ai file creator
Added tests and comments
Some refactoring