Fix #39, #40, #41, #42.
Conflicts merged