Electrical and spectroscopic studies of space-charged buildup, energy relaxation and magnetically enhanced bistability in resonant-tunneling structures