fix #283
fix #504
fix #325