Added comments to all ui components and made minor efficiency changes