Cleanup code + more testing