Remove build cruft, fix dependencies and version checks, add comments.