Base structure
First version optmized to safe e unsafe code.