moved some functions to inlines. did some cleaning up.