Portugeuse merge conflicts

Decided to fix merge conflicts of #255 caused by #256.

@fosskers: This pulls in @hkupty's changes cleanly. Sorry about the mess. I've also looked at #259 and have a while there are  conflicts, they aren't nearly as drastic. I already have a local branch waiting to merge those changes (if this is accepted first), or rebase those changes (if this is accepted after). In either case, @hkupty's work can *finally* be merged :-).