restructured some code. nothing big.