Committing changes from 2012. Not sure if everything works as expected.