Rearrange code; update to include build cfg