Cleaned up some code and fixed the BSD attributions