Refactoring

I will tag 0.02 after merging this change and release to Marmalade.