Bug fix #315 and #314