reorganizing some things

had to rearrange some things to avoid circular dependency issues and to
make it happy with compiling.