Added files for type definitions and global variables.
Refactoring, reducing amount of unnecessary code.