Merge working code to master