Reordered libraries, fixed link errors, hopefully.