Added cleanup code.
Added api routing.