Smart build

**not ready for merging yet**