Fixed linking, some cleanup