Fix some bugs.

This doesn't work anymore, so I made some changes to make it work, at least. It may be helpful for those people like me want to try this out.