Splitting into a couple of files, and added InternalTypes module for internal representations
Small code cleanups