More bug fixes, shortened code