Move constants, functions and structs to their own file.
Added changes so far for 1.4.0.