Reorganizing code and adding support for more primitive types