Bundle compiler refactor and functional tests