Updated Master

Refactored master
Added pre threading