Improve the code for #80.