Fix #53 - Refactor rsync

This is mostly a style cleanup, but I also was able to simplify a number of code paths, eliminate duplicate code, and fix a few bugs. I've also renamed a bunch of variables to make it more clear what's happening, broken things into smaller functions, and re-ordered some operations so the nesting isn't so deep.
seems like we're using err instead of error in most places; should probably stick to that convention everywhere