Refactoring

Hi,

i've refactored the module. Based on this i will submit some more PRs which add new features to the module.

Regards,
Matthias