This code was posted for comment only. It's variously flawed, and not ready for primetime.