Improve collision detection. fixes #31 again.

OMG, what a complication but it works!
Merge branch 'master' of https://github.com/eugenkiss/genericproject.git