moved some code, some include fixes