Removed flag tests
Cleaned code