Massive refactoring and basic SRT support added. Warning: API is different.