move some declarations
add missing headers
remove temp