IMPORTANT: bug fixes. May be unstable.