added dynamic_stack and cleaned up lots