Fixed ticket #82 + fixed a bug introduced in the last few commits.