fix #54, #64, partial #48
fix #54, #64, partial #48