Move Flash features into their own function
Also standardize code