Fixed a few warnings and added more exception support as well as changed file structure.