Add code.
WIP.
Fixed some bugs.