Feature/stay inside bounds

Fixes #8