bgt added, some refactoring
moved some stuff around