Small fixes and a small refactoring
Updated: random cases generator