Fixed a few bugsand included some files I was already using locally.