This simple implementation has a few issues, but it should do for 0.2.2.x. We will want to revisit this later and make it smarter.