some fixes and changes; needs cleanup!