Improved types.h and made some minor bug fixes
Significantly improved types.h, also bugfixes