Some cleanup and rebase.