Refactor and add Z-Buffer