add flip() function for #57 and detect() with options for #55 (tentative)