Clean up of code

Cleaned up the Firefly IoT imp code so it will be more stable and less
confusing to look at and read.