Adds changes from BSD site
Totally refactors code according to Mark Dalgleish's patterns