Fix bubble and clean up code