Restructure fireball.c for merging