Clean up shape detection functions