Port changes from master to ubuntu-12.04