fix #5, #6, issue 1334 on google code