A few fixes and resolve #4